<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>class Bzoo</title>
	<style type="text/css">
	/* ZenDoc identity */
	.zendoc { font-family: Arial, Helvetica, sans-serif; margin:3px; }
	.zendoc a:hover { text-decoration:none; }
	.zendoc span.title-comment { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:80%; color:#AAA; }
	.zendoc span.title-zen { color:#26A; font-weight:normal; }
	.zendoc span.title-doc { color:black; font-weight:bold; }
	/* overall */
	html, body, div { margin:0; padding:0; border:none; }
	body { font-family:Arial, Helvetica, sans-serif; font-size:90%; }
	a { text-decoration:none; }
	a:hover { text-decoration:underline; }
	h2 { color:#999; margin:2em 0 0 0; padding:0 2px 0 20px; border-bottom:2px solid #58B; }
	h3 { color:#B36B00; margin-top:3em; }
	dl { margin:.5em 0 3px 0; }
	dt { font-weight:bold; }
	td { vertical-align:top; }
	th { text-align:left; color:#58B; background-color:#E3ECF4; }
	code { font-size:1.1em; }
	/* specific */
	#header { background-color:#EAEAEA; padding:1px; }
	#links { color:#999; background-color:#FFE; border-bottom:1px solid #58B; padding:2px 20px; }
	#links a { color:#999; }
	.content { padding:10px 20px; }
	#class-definition { background-color:#58B; color:white; }
	#class-definition .classkind { font-weight:bold; }
	#class-definition .classkind .package { font-weight:normal; }
	#class-definition .classname { font-size:4em; margin:5px 0; }
	#class-definition .superclassname { padding-left:20px; font-style:italic; }
	#class-definition .implements { padding-left:20px; font-style:italic; }
	#class-info .content { margin:20px; border:1px solid #58B; }
	pre.definition { background-color:#FFE; border:1px solid #E4E29A; padding:3px; }
	.generated {
		font-style:italic;
		font-size:80%;
		color:#666;
		margin:1em 0 0 0;
		padding:5px 20px;
		border-top:1px solid #999;
	}
	/* tables */
	.member-list { border:1px solid #58B; margin:2em 20px; }
	.member-list a { color:#B36B00; }
	.member-list table { border-collapse:collapse; }
	.member-list td { border-top:1px solid #58B; }
	.member-list td.name { width:175px; text-align:right; padding-right:5px; }
	.member-list table { width:100%; }
	.even { background-color:#FFE; }
	.odd { background-color:white; }
	.param .name { color:#666; }
	</style>
</head>

<body>
<div id="page">
	<div id="header">
		<h4 class="zendoc"><a href="http://www.zendoc.org" title="ZenDoc Documentation Tool Home"><span class="title-comment">/**</span><span class="title-zen">Zen</span><span class="title-doc">Doc</span><span class="title-comment">--&gt;</span></a></h4>
	</div>
	<div id="class-definition" class="section">
		<div class="content">
			
			<div class="classkind">class <span class="package">com.rtistique.bzoo</span></div>
			<h1 class="classname">Bzoo</h1>
			
			
			
		</div>
		<div id="links">
			<a href="#class-info">Class Information</a>
			 | <a href="#class-constructors">Constructors</a>
			 | <a href="#class-properties">Properties</a>
			 | <a href="#class-methods">Methods</a>
			
		</div>
	</div>
	
	<div id="class-info" class="section">
		<h2>Class Information</h2>
		<div class="content">
			
				<dl>
					<dt>Author</dt>
					<dd>Bachir El Khoury</dd>
					
					<dt>Version</dt>
					<dd>0.1.3
- Added persistent data support
- Made find feature non case sensitive<br />0.1.2
- Update method now supports array of fields to udpate<br />0.1.0: 
- Beta Release</dd>
					
					<dt>Description</dt>
					<dd>Bzoo is an AS3 library that provides a thin data layer 
for flash/flex applications or websites, allowing data 
manipulation.<br/>
It works like a temporary database, adapting the CRUD 
interface:
<ul>
<li>Create</li>
<li>Read</li>
<li>Update</li>
<li>Delete</li>
</ul>
<br/></dd>
					
					<dt>Usage</dt>
					<dd><pre><code>import com.rtistique.bzoo.Bzoo;
var friends:Bzoo = new Bzoo(data);</code></pre>
check the working example at:
http://rtistique.com/blog/?page_id=23</dd>
					
				</dl>
			
			
			</div>
			
			
			<div class="member-list">
			<table><tr><th colspan="2">Constructors</th></tr>
				<tr class="even">
					<td class="name"><a href="#Bzoo">Bzoo()</a></td>
					<td>The Bzoo constructor method takes data object and data type string as parameters</td>
				</tr>
			</table></div>
			
			
			<div class="member-list">
			<table><tr><th colspan="2">Properties</th></tr>
				<tr class="even">
					<td class="name"><a href="#FIND_ALL">FIND_ALL</a></td>
					<td>Static string constant "all"</td>
				</tr><tr class="odd">
					<td class="name"><a href="#FIND_FIRST">FIND_FIRST</a></td>
					<td>Static string constant "first"</td>
				</tr><tr class="even">
					<td class="name"><a href="#FIND_COUNT">FIND_COUNT</a></td>
					<td>Static string constant "count"</td>
				</tr><tr class="odd">
					<td class="name"><a href="#ASCENDING">ASCENDING</a></td>
					<td>Static string constant "ascending"</td>
				</tr><tr class="even">
					<td class="name"><a href="#DESCENDING">DESCENDING</a></td>
					<td>Static string constant "descending"</td>
				</tr><tr class="odd">
					<td class="name"><a href="#NUMERIC">NUMERIC</a></td>
					<td>Static string constant "numeric"</td>
				</tr><tr class="even">
					<td class="name"><a href="#TYPE_AMF">TYPE_AMF</a></td>
					<td>Data type static string constant "amf"</td>
				</tr><tr class="odd">
					<td class="name"><a href="#TYPE_YAML">TYPE_YAML</a></td>
					<td>Data type static string constant "yaml"</td>
				</tr><tr class="even">
					<td class="name"><a href="#TYPE_JSON">TYPE_JSON</a></td>
					<td>Data type static string constant "json"</td>
				</tr><tr class="odd">
					<td class="name"><a href="#data">data</a></td>
					<td>Data collection</td>
				</tr><tr class="even">
					<td class="name"><a href="#isPersistent">isPersistent</a></td>
					<td>Set data persistence</td>
				</tr>
			</table></div>
			
			
			<div class="member-list">
			<table><tr><th colspan="2">Methods</th></tr>
				<tr class="even">
					<td class="name"><a href="#find">find()</a></td>
					<td>The find method takes type, conditions, fields and orderBy params and returns filtered array results</td>
				</tr><tr class="odd">
					<td class="name"><a href="#insert">insert()</a></td>
					<td>Insert a new data object or an array of objects</td>
				</tr><tr class="even">
					<td class="name"><a href="#remove">remove()</a></td>
					<td>Delete object that matches criteria</td>
				</tr><tr class="odd">
					<td class="name"><a href="#removeByIndex">removeByIndex()</a></td>
					<td>Delete by index object form data</td>
				</tr><tr class="even">
					<td class="name"><a href="#update">update()</a></td>
					<td>Update objects that matches criteria</td>
				</tr><tr class="odd">
					<td class="name"><a href="#orderBy">orderBy()</a></td>
					<td>Sort data array</td>
				</tr><tr class="even">
					<td class="name"><a href="#clearData">clearData()</a></td>
					<td>Clear persistent data from SO</td>
				</tr><tr class="odd">
					<td class="name"><a href="#checkPersistance">checkPersistance()</a></td>
					<td>Check data persistence. If true data is retrieved from Shared Object.</td>
				</tr><tr class="even">
					<td class="name"><a href="#flushData">flushData()</a></td>
					<td>Save data to Shared Object</td>
				</tr><tr class="odd">
					<td class="name"><a href="#setPersistence">setPersistence()</a></td>
					<td>Set data persistence</td>
				</tr>
			</table></div>
			
			
	</div>
		
	<br />
	
	<div id="class-constructors" class="member-group section">
		<h2>Constructors</h2>
		<div class="content">
			<div class="member-item">
				<h3 id="Bzoo">Bzoo()</h3>
				<pre class="definition"><code>public function Bzoo(data:Object, type:String = TYPE_AMF, isPersistent:Boolean = false, name:String = "bzoo")</code></pre>
				<div>The Bzoo constructor method takes data object and data type string as parameters</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>data</code></td><td>Data object that can either be an array of similar objects, a JSON string or a YAML string</td></tr>
					<tr><td class="name"><code>type</code></td><td>The data type. Default "amf". Other values can be "json" or "yaml"</td></tr>
					</table></dd>
				</dl>
				
				
			<dl>
					<dt>Example:</dt>
					<dd><pre>
var data:Array = [
	{name:"Bob",
	  gender:"M",
	  married:"No",
	  age:25,
	  state:"NY",
	  favorite_foods:["pizza","tacos"]},
	{name:"Joyce",
	  gender:"F",
	  married:"No",
	  age:29,
	  state:"WA",
	  favorite_foods:["salad","cheese sticks"]},
	{name:"Dan",
	  gender:"M",
	  married:"No",
	  age:29,
	  state:"MT",
	  favorite_foods:["pizza","hamburgers","BLTs"]},
	{name:"Sarah",
	  gender:"F",
	  married:"No",
	  age:21,
	  state:"ID",
	  favorite_foods:["pizza","sushi"]}
	  ];
<br/><b>var friends:Bzoo = new Bzoo(data);</b></dd>
				</dl>
			
			
			
			</div>
		</div>
	</div>
	<br />
	<div id="class-properties" class="member-group section">
		<h2>Properties</h2>
		<div class="content">
			<div class="member-item">
				<h3 id="FIND_ALL">FIND_ALL</h3>
				<pre class="definition"><code>public static const FIND_ALL :String</code></pre>
				<div>Static string constant "all"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="FIND_FIRST">FIND_FIRST</h3>
				<pre class="definition"><code>public static const FIND_FIRST :String</code></pre>
				<div>Static string constant "first"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="FIND_COUNT">FIND_COUNT</h3>
				<pre class="definition"><code>public static const FIND_COUNT :String</code></pre>
				<div>Static string constant "count"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="ASCENDING">ASCENDING</h3>
				<pre class="definition"><code>public static const ASCENDING :String</code></pre>
				<div>Static string constant "ascending"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="DESCENDING">DESCENDING</h3>
				<pre class="definition"><code>public static const DESCENDING :String</code></pre>
				<div>Static string constant "descending"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="NUMERIC">NUMERIC</h3>
				<pre class="definition"><code>public static const NUMERIC :String</code></pre>
				<div>Static string constant "numeric"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="TYPE_AMF">TYPE_AMF</h3>
				<pre class="definition"><code>public static const TYPE_AMF :String</code></pre>
				<div>Data type static string constant "amf"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="TYPE_YAML">TYPE_YAML</h3>
				<pre class="definition"><code>public static const TYPE_YAML :String</code></pre>
				<div>Data type static string constant "yaml"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="TYPE_JSON">TYPE_JSON</h3>
				<pre class="definition"><code>public static const TYPE_JSON :String</code></pre>
				<div>Data type static string constant "json"</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="data">data</h3>
				<pre class="definition"><code>public function get data():Array</code></pre>
				<div>Data collection</div>
				
			
			
			
			
			</div>
		</div><div class="content">
			<div class="member-item">
				<h3 id="isPersistent">isPersistent</h3>
				<pre class="definition"><code>public function get isPersistent():Boolean</code></pre>
				<div>Set data persistence</div>
				
			
			
			
			
			</div>
		</div>
	</div>
	<br />
	<div id="class-methods" class="member-group section">
		<h2>Methods</h2>
		<div class="content">
			<div class="member-item">
				<h3 id="find">find()</h3>
				<pre class="definition"><code>public function find(type:String = FIND_ALL, params:Object = null):Object</code></pre>
				<div>The find method takes type, conditions, fields and orderBy params and returns filtered array results</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>type</code></td><td>String. "all", "first", "count"</td></tr>
					<tr><td class="name"><code>params</code></td><td>Object holding conditions, fields and orderBy params</td></tr>
					</table></dd>
				</dl>
				<dl>
					<dt>Returns:</dt>
					<dd>filtered Array result</dd>
				</dl>
				
			<dl>
					<dt>Example:</dt>
					<dd><pre>
<br/>
// Example 1: 
// Finding all people that are 29 years old
var result:Object = bzoo.find("all", { 
				conditions	:[{ field:"age", equal:"29"}]);
<br/>
// Example 2: 
// The result will be an object with only the name and the state attributes, where person's age is greater than 21
// sort the result by state Ascending
var result:Object = bzoo.find("all", { 
				fields		:["name", "state"], 
				conditions	:[{ field:"age", greaterThan:"21"}], 
				orderBy		:{ field:"state", order:Bzoo.ASCENDING} } ); 
<br/>
// Example 3: 
// Finding the first person that is 29 years old
var result:Object = bzoo.find("first", { 
				conditions	:[{ field:"age", greaterThan:"21"}]);
<br/>
</pre></dd>
				</dl>
			
			
			
			</div><div class="member-item">
				<h3 id="insert">insert()</h3>
				<pre class="definition"><code>public function insert(data:Object):void</code></pre>
				<div>Insert a new data object or an array of objects</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>data</code></td><td>Object or array to be inserted</td></tr>
					</table></dd>
				</dl>
				
				
			<dl>
					<dt>Example:</dt>
					<dd><pre>
<br/>
bzoo.insert( { name:"Bachir", 
		gender:"M", 
		married:"YES", 
		age: 28, 
		state:"NSW", 
		favorite_food:["Moussaka", "Akroshka"] });
<br/>
</pre></dd>
				</dl>
			
			
			
			</div><div class="member-item">
				<h3 id="remove">remove()</h3>
				<pre class="definition"><code>public function remove(params:Object):Array</code></pre>
				<div>Delete object that matches criteria</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>params</code></td><td><tt>Object</tt> Holding conditions, fields and orderBy params</td></tr>
					</table></dd>
				</dl>
				<dl>
					<dt>Returns:</dt>
					<dd>filtered Array result</dd>
				</dl>
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="removeByIndex">removeByIndex()</h3>
				<pre class="definition"><code>public function removeByIndex(index:Number):Array</code></pre>
				<div>Delete by index object form data</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>index</code></td><td><tt>Number</tt> Index of the object to be deleted</td></tr>
					</table></dd>
				</dl>
				<dl>
					<dt>Returns:</dt>
					<dd>udpated array after deletion</dd>
				</dl>
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="update">update()</h3>
				<pre class="definition"><code>public function update(params:Object, values:Object):Array</code></pre>
				<div>Update objects that matches criteria</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>params</code></td><td><tt>Object</tt> Holding conditions, fields and orderBy params</td></tr>
					<tr><td class="name"><code>values</code></td><td><tt>Object</tt> New object values to be set for the object</td></tr>
					</table></dd>
				</dl>
				<dl>
					<dt>Returns:</dt>
					<dd>udpated array after update</dd>
				</dl>
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="orderBy">orderBy()</h3>
				<pre class="definition"><code>public function orderBy(orderBy:String, orderType:String):Array</code></pre>
				<div>Sort data array</div>
				<dl>
					<dt>Parameters:</dt>
					<dd><table class="param">
						<tr><td class="name"><code>orderBy</code></td><td><tt>String</tt> field name the array will be sorted by</td></tr>
					<tr><td class="name"><code>orderType</code></td><td><tt>String</tt> The sorting type "ascending", "descending", "numeric"</td></tr>
					</table></dd>
				</dl>
				<dl>
					<dt>Returns:</dt>
					<dd>sorted array</dd>
				</dl>
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="clearData">clearData()</h3>
				<pre class="definition"><code>public function clearData():void</code></pre>
				<div>Clear persistent data from SO</div>
				
				
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="checkPersistance">checkPersistance()</h3>
				<pre class="definition"><code>private function checkPersistance():void</code></pre>
				<div>Check data persistence. If true data is retrieved from Shared Object.</div>
				
				
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="flushData">flushData()</h3>
				<pre class="definition"><code>private function flushData():void</code></pre>
				<div>Save data to Shared Object</div>
				
				
				
			
			
			
			
			</div><div class="member-item">
				<h3 id="setPersistence">setPersistence()</h3>
				<pre class="definition"><code>private function setPersistence():void</code></pre>
				<div>Set data persistence</div>
				
				
				
			
			
			
			
			</div>
		</div>
	</div>
	
	<p class="generated">Page generated: 1:26 am on February 15, 2009</p>
</div>
</body>
</html>